package com.example.mystore.service.impl;

import com.example.mystore.mapper.UserCommodityMapper;
import com.example.mystore.model.Product;
import com.example.mystore.service.UserCommodityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class UserCommodityServiceImpl implements UserCommodityService {

    private final UserCommodityMapper userCommodityMapper;

    @Autowired
    public UserCommodityServiceImpl(UserCommodityMapper userCommodityMapper) {
        this.userCommodityMapper = userCommodityMapper;
    }

    @Override
    public List<Product> getHotUserCommodities() {
        return userCommodityMapper.getHotUserCommodities();
    }
    @Override
    public List<Product> getProductsByProductId(Integer productId) {
        return userCommodityMapper.getProductsByProductId(productId);
    }


    @Override
    public List<Product> searchProductsByKeyword(String keyword) {
        return userCommodityMapper.searchProductsByKeyword(keyword);
    }
}
